public class Demo7 {
    public static boolean isFinished = false;

    public static void main(String[] args) throws InterruptedException {
        //final boolean isFinished = false;//如果lamada在main函数内部，必须加上final修饰，不能让该值改变
        Thread t = new Thread(() -> {
            while (!isFinished) {
                System.out.println("hello t");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
        t.start();

        Thread.sleep(10000);
        isFinished = true;

    }

}
